/**
 * Copyright 2010 Victor Egea Hernando
 *
 * RockScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * RockScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with RockScript.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef PJIT_CODEGEN_X86_H_
#define PJIT_CODEGEN_X86_H_

#include "pjit_x86.h"
#include "pjit_asm_x86.h"

#if PICOJIT_TARGET == 1 || PICOJIT_TARGET == 2

namespace pjit{

class pjit_codegen_x86 : public pjit_codegen {

public:
	// CONSTRUCTOR & DESTRUCTOR
	pjit_codegen_x86( void );
	virtual ~pjit_codegen_x86();
	// MAIN INTERFACE (COMPILE)
	virtual void compile( pjit_block &block, pjit_buffer &buffer );

protected:
	// INNER PROPERTIES
	__x86_flags   _flags;
	// NUMBER OF BYTES PUSHED BEFORE CALLING A FUNCTION
	uint32 _nbytes_pushed;
	// NUMBER OF BYTES RESERVED BY THE BLOCK
	uint32 _nbytes_sp;

protected:
	// HELPFUL FUNCTIONS
	void save_stack_conntext( pjit_asm_x86 &asm_x86 );
	void skip_n_bytes( pjit_asm_x86 &asm_x86, uint32 bytes );

};

};

#endif // PICOJIT_TARGET == 1 || PICOJIT_TARGET == 2

#endif // PJIT_CODEGEN_X86_H_
